package com.services;

import com.dao.*;
import com.mapper.Data;
import com.mapper.wx;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.concurrent.ExecutionException;

@Service
@Component
public class WxServices {
    @Autowired
    private wx wxs;
    @Autowired
    private Data data;
    public wxuser getWxUseByOpenId(String openID){

        return wxs.getWxUserByOpenId(openID);
    }
    public user getUseByOpenId(String openID){
        return wxs.getUserByOpenId(openID);
    }
    public void insert(wxuser user){
        wxs.insertIntoWxUser(user);
    }
    public void insertIntoUser(user user){
        wxs.insertIntoUser(user);
    }
    public inspector getInspector(String openid){
        return wxs.getInspectorByOpenId(openid);
    }
    public void insertIntoInspector(inspector inspector){
        wxs.insertIntoInspector(inspector);
    }
    public void insertIntoOuts(outs outs){
        wxs.insertIntoOuts(outs);
    }
    public void insertIntoEnter(outs outs){
        wxs.insertIntoEnter(outs);
    }
    public int[] getData_Number(String time){
        int a[] = new int[4];
        try {
            a[0] = data.getUser_number();
        }catch (Exception e){
            a[0] = 0;
        };
        try {
            a[1] = data.getInspector_number();
        }catch (Exception ex) {
            a[1] = 0;
        }
        a[2] = data.getDay_out(time);
//        try {
//
//            a[2] = data.getDay_out(time);
//        }catch (Exception ex){
//            System.out.println(time+"异常1");
//            a[2]=0;
//        }
        try{
            a[3] = data.getDay_enter(time);
        }catch (Exception e) {
            System.out.println(time+"异常2");
            a[3] = 0;
        }
        return a;
    }
    public void insertIntoTrans_Inspector(trans_inspector trans){
        wxs.insertIntoTrans_Inspectot(trans);
    }
    public trans_inspector getTrans(String openid){
        return wxs.getTrans(openid);
    }
}
